package com.brspace.qualitycontrol.controller.admin;


import com.brspace.qualitycontrol.entity.IncomingCall;
import com.brspace.qualitycontrol.entity.PeopleHotline;
import com.brspace.qualitycontrol.service.IncomingCallService;
import com.brspace.qualitycontrol.service.ProcessNodeService;
import com.brspace.qualitycontrol.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 来电 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-05-06
 */
@Api(description = "来电")
@RestController
@RequestMapping("/admin/incoming-call")
public class IncomingCallController {
    @Resource
    private IncomingCallService callService;
    @Resource
    private ProcessNodeService processNodeService;
    @ApiOperation("来电录入")
    @PostMapping("add")
    public R add(@ApiParam(value = "来电对象") @RequestBody IncomingCall call){
        if (callService.add(call)>0) {
            return R.ok().data("message","添加成功");
        }
        return R.error();
    }
    @ApiOperation("根据ID查询单个")
    @GetMapping("findById/{id}")
    public R  findById(@ApiParam(value = "id",required = true) @PathVariable String id){

        return R.ok().data("list",callService.findById(id)).data("sort",processNodeService.findCall(id));
    }
    @ApiOperation("审核")
    @PostMapping("examine/{userName}/{uid}")
    public R examine(
            @ApiParam(value = "下阶段办理人ID" ,required = true) @PathVariable String userName,
            @ApiParam(value = "当前节点办理人ID" , required = true) @PathVariable String uid,
            @ApiParam("对象类型") @RequestBody IncomingCall call){
        return callService.examine(call,userName,uid);
    }


}

